﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace Jw.Utils.Helper
{
    public class NetHelper
    {
        /// <summary>
        /// 获取本机Mac地址 
        /// </summary>
        /// <returns></returns>
        public static string GetMACAddress()
        {
            string MacAddress = "";
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if ((bool)mo["IPEnabled"] == true)
                    MacAddress = mo["MacAddress"].ToString();
                mo.Dispose();
            }

            return MacAddress;

        }
    }
}
